import { Image, Text, Video, View } from "@tarojs/components";
import { useEffect, useState } from "react";
import Taro from '@tarojs/taro';
import "./index.scss";
import request from "../../utils/request";



export default function Cat() {
  const [data, setData] = useState<string>('');


  useEffect(() => {
    getData()
  }, []);

  const getData = async () => {
    Taro.showLoading({
      title: "加载中"
    });

    const data = await request({  method: "GET",
    url: '/meinv'
    ,})

    Taro.hideLoading();
    if (data.data) {
      setData(data.data)
    }
  }

  const changeNext=()=>{
    getData()
  }

  // const imgYu = (current: string) => {
  //   Taro.previewImage({
  //     current,
  //     urls: [current]
  //   })
  // }



  return <View className='box' >
    {
      data? <Video src={data} className="videoddd" />:<Text>暂无视频</Text>
    }
      <View className="change-btn" onClick={changeNext}>换一张</View>
  </View>
}
